;;(load "sym.scm")


(define (get-deli s m n st)
  (let* ((len (string-length s))
         (c (if (< n len) (string-ref s n)))
	 )
    (cond
      ((= n len)
       (cond
	((eq? st '语句终结和结束分隔符)
	 (list (substring s m n) n '结束分隔符))
	((or (eq? st '分隔符)(eq? st '语句终结分隔符)(eq? st '函数定义分隔符))
	 (list (string-append (substring s m n) "\n") n '结束分隔符))
	((eq? st '结束分隔符)
	 (list (substring s m n) n st))
	(else (list #f n st '非法分隔符状态))))
      ((and (not (eq? st '语句终结分隔符))(char=? c #\newline))
       (set! st '结束分隔符)
       (get-deli s m (+ n 1) st))
      ((and (eq? st '语句终结分隔符)(char=? c #\newline))
       (set! st '语句终结和结束分隔符)
       (get-deli s m (+ n 1) st))
      ((char=? c #\。)
       (set! st '语句终结分隔符)
       (get-deli s m (+ n 1) st))
      ((and (or (eq? st '语句终结分隔符)(eq? st '语句终结和结束分隔符))(rd-p-deli c))
       (set! st '语句终结分隔符)
       (get-deli s m (+ n 1) st))
      ((rd-p-deli c)
       (set! st '分隔符)
       (get-deli s m (+ n 1) st))
      (else
       (if (eq? st '语句终结和结束分隔符) (set! st '结束分隔符))
       (cond
	((and (string=? (substring s m n) "\n\t") (eq? cyl-define-status 'func-define))
	 ;;(set! cyl-line-begin #f)
	 (list (substring s m n) (- n 1) '分隔符))
	((string=? (substring s m n) "\n\t")
	 ;;(set! cyl-line-begin #f)
	 (list (substring s m n) (- n 1) '函数定义分隔符))
	((and (string=? (substring s m n) "\n\t") (eq? cyl-define-status 'func-define))
	 ;;(set! cyl-line-begin #f)
	 (list (substring s m n) (- n 1) '分隔符))
	((or (eq? st '分隔符)(eq? st '语句终结分隔符))
	 ;;(set! cyl-line-begin #f)
	 (list (substring s m n) (- n 1) st))
	((eq? st '结束分隔符)
	 ;;(set! cyl-line-begin #t)
	 (list (substring s m n) (- n 1) st))
	(else (list #f (- n 1) '非法分隔符状态)))))))
